package com.qf.myschool.servlet;

import com.qf.myschool.service.IStudentService;
import com.qf.myschool.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 操作学生的Servlet
 */
@WebServlet("/StudentServlet")
public class StudentServlet extends SuperServlet {
	private static final long serialVersionUID = 1L;

	/**
	*创建学生业务对象
	*/
	IStudentService stuService=new StudentServiceImpl();



	private String isUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//1.接收请求中数据
		String uname=request.getParameter("uname1");

		//2.调用相应业务去处理请求,并得到结果
		String result=stuService.isStudent(uname);

		//3.将结果以字符串方式响应给ajax引擎对象
		return "ajax:"+result;
	}

	/**
	 * 注销
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private String exit(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//清空session中用户数据
		request.getSession().removeAttribute("stu");
		//重定向到登录页面
		return "redirect:login.jsp";
	}

}
